﻿// -------------------------------------------------------------------------
//    @FileName         :    NFTransSaveRole.cpp
//    @Author           :    Gao.Yi
//    @Date             :    2025-08-18
//    @Email			:    445267987@qq.com
//    @Module           :    NFTransSaveRole
//    @Desc             :
//
// -------------------------------------------------------------------------

#include "NFTransSaveRole.h"

#include "NFPlayer.h"
#include "proto_db.pb.h"
#include "NFLogicCommon/NFBaseDefine.h"

NFTransSaveRole::NFTransSaveRole()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFTransSaveRole::~NFTransSaveRole()
{
}

int NFTransSaveRole::CreateInit()
{
    return 0;
}

int NFTransSaveRole::ResumeInit()
{
    return 0;
}

int NFTransSaveRole::SaveDb(NFPlayer* pPlayer, int iReason)
{
    CHECK_NULL(m_roleId, pPlayer);
    Init(NF_ST_LOGIC_SERVER, m_roleId, E_TABLE_ROLE_DETAIL, pPlayer->GetGlobalId(), 0);
    m_reason = iReason;

    proto_ff::tbRoleDetail tbData;
    pPlayer->SaveDB(&tbData);
    NFLogTrace(NF_LOG_DEFAULT, m_roleId, "Ready Save Player InTo Db:{}", tbData.DebugString());
    return SaveCacheDataReq(pPlayer, iReason, tbData);
}
